#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#define BUFSIZE	1024

int main(int argc, char **argv)
{
	int fd;
	int ret;

	fd = open(argv[1], O_RDWR);
	if (fd < 0) {
		perror("Open");
		ret = fd;
		goto err_0;
	}

	ret = write(fd, argv[2], strlen(argv[2]));
	if (ret < 0) {
		perror("Write");
		goto err_1;
	}

	close(fd);

	printf("%s, %s, writed.\n", argv[1], argv[2]);

	return 0;

err_1:
	close(fd);
err_0:
	return ret;
}
